home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Precision Software Appli…tions Silver Collection 1
/
Precision Software Applications Silver Collection Volume One (PSM) (1993).iso
/
windows
/
games
/
mshfun.arj
/
BURST2.C
< prev
next >
Wrap
Text File
|
1989-01-18
|
4KB
|
138 lines
/***********************************************************************
* This program was originally written by Michael Harrison [76057,101] *
* I made the same modifications to this program as to burst and face. *
* Since this program only pops up the bitmap once, it doesn't suffer *
* from the same problems the others did, but I made the changes as a *
* matter of style. That way, is the user wanted it to stay around, *
* and recompiled it, it wouldn't hog memory when changed. *
* Perri Nelson [71401,2116] *
***********************************************************************/
#include <windows.h>
#include <stdlib.h>
long FAR PASCAL WndProc (HWND, unsigned, WORD, LONG);
void FAR PASCAL TimerProc(HWND, unsigned, WORD, LONG);
HANDLE hInst;
/* Moved from WndProc to make available to WinMain as well */
static HANDLE hBitmap;
int PASCAL WinMain (hInstance, hPrevInstance, lpszCmdLine, nCmdShow)
HANDLE hInstance, hPrevInstance;
LPSTR lpszCmdLine;
int nCmdShow;
{
HWND hWnd;
MSG msg;
WNDCLASS wndclass;
FARPROC lpfnTimerProc;
if (!hPrevInstance)
{
wndclass.style = CS_HREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInstance;
wndclass.hIcon = NULL;
wndclass.hCursor = LoadCursor (hInstance, IDC_ARROW);
wndclass.hbrBackground = GetStockObject (WHITE_BRUSH);
wndclass.lpszMenuName = NULL;
wndclass.lpszClassName = "Burst2";
if (!RegisterClass (&wndclass) )
return FALSE;
}
else
return FALSE; /* only allow one instance */
hInst=hInstance;
hWnd = CreateWindow ("Burst2", "Burst2", WS_OVERLAPPEDWINDOW, 0, 0,
0,0, NULL, NULL, hInstance, NULL);
/* wait one minute before doing anything */
if(!SetTimer(hWnd, 1, 60000+(rand()*10), NULL))
{
MessageBox(hWnd, "Too many clocks or timers!", "Burst2",
MB_ICONEXCLAMATION | MB_OK);
return FALSE;
}
/* Moved from WndProc to improve memory usage */
hBitmap=LoadBitmap(hInst, "Burst2");
while (GetMessage(&msg, NULL, 0,0 ))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return msg.wParam;
}
long FAR PASCAL WndProc (hWnd, iMessage, wParam, lParam)
HWND hWnd;
unsigned iMessage;
WORD wParam;
LONG lParam;
{
BITMAP bm;
HDC hDC,hMemDC;
short nRand;
long xStart, yStart;
static char cJunk=0;
unsigned int nIndex;
static int nNoise=0;
switch (iMessage)
{
case WM_TIMER:
if(rand() < 2000)
{
GetObject(hBitmap, sizeof(BITMAP), (LPSTR) &bm);
hDC=CreateDC("DISPLAY", NULL, NULL, NULL);
hMemDC=CreateCompatibleDC(hDC);
SelectObject(hMemDC, hBitmap);
xStart= (GetSystemMetrics(SM_CXSCREEN)/2)-(bm.bmWidth/2);
yStart= (GetSystemMetrics(SM_CYSCREEN)/2)-(bm.bmHeight/2);
BitBlt(hDC, (short)xStart, (short)yStart, bm.bmWidth, bm.bmHeight,
hMemDC, 0,0, SRCAND);
DeleteDC(hDC);
DeleteDC(hMemDC);
OpenSound();
StopSound();
SetSoundNoise(nNoise++, 100);
StartSound();
for (nIndex=0; nIndex < 65535; nIndex++); /* pause */
SendMessage( hWnd, WM_CLOSE, 0, 0L );
}
break;
case WM_CREATE:
srand((unsigned)GetTickCount());
break;
case WM_DESTROY:
DeleteObject(hBitmap);
PostQuitMessage(0);
CloseSound();
StopSound();
KillTimer( hWnd, 1 );
break;
default:
return (DefWindowProc(hWnd, iMessage, wParam, lParam));
}
return 0L;
}